package io.renren.project.demo.controller;


import io.renren.common.utils.R;
import io.renren.modules.wyzsphone.utils.Utils;
import io.renren.project.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    DemoService demoService;

    @RequestMapping("/getNumber")
    public R getSalesOrder(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getNumber(params);
        return R.ok().put("data", o);
    }


    @RequestMapping("/getAllTask")
    public R getAllTask(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getAllTask(params);
        return R.ok().put("data",o);
    }

    @RequestMapping("/getSalesLogist")
    public R getSalesLogist(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getSalesLogist(params);
        return R.ok().put("data",o);
    }

    @RequestMapping("/getSalesItem")
    public R getSalesItem(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getSalesItem(params);
        return R.ok().put("data",o);
    }

    @RequestMapping("/getAllOrder")
    public R getAllOrder(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getAllOrder(params);
        return R.ok().put("data",o);
    }

    @RequestMapping("/getOrderDetail")
    public R getOrderDetail(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getOrderDetail(params);
        return R.ok().put("data",o);
    }

    @RequestMapping("/getAllSalesCarByorder")
    public R getAllSalesCarByorder(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.getAllSalesCarByorder(params);
        return R.ok().put("data",o);
    }

    //作废任务单
    @RequestMapping("/cancleTask")
    public R cancleTask(@RequestBody String jsonStr)
    {
        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Map o= demoService.cancleTask(params);
        return R.ok().put("data",o);
    }

    //新增任务单
    @RequestMapping("/addTask")
    public R addTask(@RequestBody String jsonStr )
    {


        Map<String,Object> params = Utils.JsonToMap(jsonStr);
        Utils.setDoubleToInt(params,"organizeId");
        Utils.setDoubleToInt(params,"balance");
        Map o= demoService.addTask(params);
        return R.ok().put("data",o);
    }

}
